﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Platformer1
{
  class BloodSplat : Fireball
  {
    public double startTime;

    public BloodSplat()
    {
    }

    public BloodSplat(Level level, Vector2 position, SpriteEffects inflip)
    {
        bActive = true;
        startTime = 0.0f;
        this.level = level;
        this.position = position;
        this.flip = inflip;
        this.duration = 2;
        LoadContent();
    }

    public override void Update(GameTime gameTime)
    {
      startTime += gameTime.ElapsedGameTime.TotalSeconds;
         fElapsed += (float)gameTime.ElapsedGameTime.TotalSeconds;
         if (fElapsed > fUpdateInterval)
         {
             duration--;
         }
         if (duration <= 0)
         {
             bActive = false;
         }

    }

    public override void LoadContent()
    {
      texture = Level.Content.Load<Texture2D>("Sprites/Blood/bloodsplat1");
      origin = new Vector2(texture.Width / 2.0f, texture.Height / 2.0f);
      mymovementanimation = new Animation(texture, .1f, true);
      fball = new AnimationPlayer();
      //collectedSound = Level.Content.Load<SoundEffect>("Sounds/PowerUp");
    }

    public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
      if (bActive)
      {
        //spriteBatch.Draw(, new Vector2 (position.X, position.Y), Color.White);
        fball.PlayAnimation(mymovementanimation);
        float scale = 1.0f + 10.0f*(float)(startTime / 5.0);
        scale = MathHelper.Clamp(scale, 1.0f, 10.0f);
        fball.Draw(gameTime, spriteBatch, position, flip, 1.0f);
      }
    }
  }
}
